feature: add error_test.go in pkg/utils#984
Open
CygnusMaximillian wants to merge 1 commit into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #984 +/- ##
=========================================
- Coverage 10.99% 9.34% -1.65%
=========================================
Files 173 321 +148
Lines 8671 16081 +7410
=========================================
+ Hits 953 1503 +550
- Misses 7612 14444 +6832
- Partials 106 134 +28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Signed-off-by: CygnusMaximillian <dprajjwal11@gmail.com>
aa9e655 to
d640e6b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request introduces unit tests for the error parsing utilities located in
pkg/utils/error.go(ParseHarborErrorCodeandParseHarborErrorMsg).Robust error handling is critical for the CLI's user experience. These functions are responsible for translating raw HTTP errors and API payloads into human-readable messages. Ensuring they work correctly prevents the CLI from displaying confusing, opaque, or raw JSON errors to end-users. This PR adds an isolated suite of table-driven tests to verify these functions against various expected error formats without altering any existing application logic.
Type of Change
Please select the relevant type.
Changes
pkg/utils/error_test.go.TestParseHarborErrorMsgto verify error extraction fromnilerrors, generic Go errors, and structured Harbor API payload errors.TestParseHarborErrorCodeto verify status code extraction from bracketed formats (e.g.,[GET ...][404]) and status formats (e.g.,(status 500)).